const jwt = require('jsonwebtoken')

module.exports = () => {
    return async (ctx,next) => {
        const { app, socket, logger, helper } = ctx;
        const client = socket.id;
        const nsp = app.io.of('/admin');
        const query = socket.handshake.query;
        const { room } = query
        const id = socket.id;
        socket.join(room)
        nsp.to(room).emit('online', {
            action: 'join',
            target: 'participator',
            message: `User(${id}) joined.`,
        });
        await next()
    }
}